home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / irix / scripts / rcs / co-script < prev    next >
Encoding:
Text File  |  1994-08-02  |  3.0 KB  |  112 lines

  1. #! /bin/csh -f
  2. #
  3. # $Id: co-script,v 1.6 92/10/27 10:07:58 carlson Exp $
  4. #
  5. # co-script    Performs a co on the file passed and write enables it.
  6. #
  7. #    Added functionality includes:
  8. #    1. Always performs default options $opt.
  9. #    2. Performs options found in environment variable RCSOPTS.
  10. #    3. Passes arguments from command line to co.
  11. #    4. Write enables files checked out if -W option given.
  12. #    5. Performs options found in file .rcsopts.
  13. #
  14. # Revision History:
  15. #    $Log:    co-script,v $
  16. # Revision 1.6  92/10/27  10:07:58  carlson
  17. # When breaking out the options, break out three characters instead of
  18. #   just two to allow checking of just the character following the dash.
  19. # Remove default options that conflict with command line options.
  20. # Revision 1.5  92/01/22  15:21:10  carlson
  21. # No longer set the time of the file to that in the RCS file.
  22. # Revision 1.4  91/08/27  13:24:54  carlson
  23. # Fixed problems with handling new .rcsopts file.
  24. # Revision 1.3  91/08/27  13:11:06  carlson
  25. # Allow new style .rcsopts files.
  26. # Added comments.
  27. # Exit if co doesn't work.
  28. # Revision 1.2  91/07/29  09:00:30  chris
  29. # Cleaned up to use less code.  Doesn't separate option from argument
  30. #   anymore and then put them back together.
  31. # Added RCS symbols.
  32. #------------------------------------------------------------------------
  33. # Set default options for co command here.
  34. #
  35. set opt = ( )
  36. if ( $?RCSOPTS ) then
  37.     set opt = ( $opt $RCSOPTS )
  38. endif
  39. if ( -e ./.rcsopts ) then
  40.     set x = ( `grep "^co[     ]" ./.rcsopts` )
  41.     if ( $#x > 1 ) then
  42.     set opt = ( $opt $x[2-] )
  43.     else
  44.     set x = ( `cat ./.rcsopts` )
  45.     if ( "$x[1]" != "ci" && "$x[1]" != "col" ) then
  46.         echo "*** Old style .rcsopts file ***"
  47.         set opt = ( $opt `cat ./.rcsopts` )
  48.     endif
  49.     endif
  50. endif
  51. set setwrt = 0
  52.  
  53. #----
  54. # Scan for end of options in parameter list.  We need to do this to
  55. # find where the file names start.
  56. #
  57. # While scanning, do the following:
  58. #    1. Remove any duplicated options from $opt.
  59. #    2. Check for -W option and set flag to remind us to write
  60. #       enable the file when we're done.
  61. #
  62. @ first = 1
  63.  
  64. while ( $first <= $#argv )
  65.     set arg_chars = ( `echo $argv[$first] | sed "s/\(.\)\(.\)\(.\)/\1 \2 \3/\\
  66. s/\(.\)\(.\)/\1 \2/"` )
  67.     if ( "$arg_chars[1]" != "-" ) break
  68.     if ( "$arg_chars[2]" == "-" ) then
  69.     set argv[$first]
  70.     break
  71.     endif
  72.     @ secnd = 1
  73.     while ( $secnd <= $#opt )
  74.     set opt_chars = ( `echo $opt[$secnd] | sed "s/\(.\)\(.\)\(.\)/\1 \2 \3/\\
  75. s/\(.\)\(.\)/\1 \2/"` )
  76.     if ( "$opt_chars[1]" != "-" ) break
  77.     if ( "$opt_chars[2]" == "$arg_chars[2]" ) set opt[$secnd]
  78.     if ( "$opt_chars[2]" == "u" && "$arg_chars[2]" == "l" ) \
  79.         set opt[$secnd]
  80.     if ( "$opt_chars[2]" == 'l' && "$arg_chars[2]" == "u" ) \
  81.         set opt[$secnd]
  82.     @ secnd = $secnd + 1
  83.     end
  84.     if ( "$argv[$first]" == "-W" ) then
  85.     set argv[$first]
  86.     set setwrt = 1
  87.     endif
  88.     @ first=$first + 1
  89. end
  90.  
  91. #----
  92. # Check out files with arguments passed.
  93. #
  94. /usr/sbin/co $opt $argv
  95. if ( $status != 0 ) exit $status
  96.  
  97. #----
  98. # Write enable files.
  99. #
  100. if ( $setwrt == 1 ) then
  101.     chmod ug+w $argv[$first-]
  102. endif
  103.  
  104. ### Local Variables:
  105. ### auto-fill-hook: nil
  106. ### End:
  107.